package com.e7.action;

import java.io.IOException;
import java.io.InputStream;

import org.springframework.stereotype.Component;

import com.e7.common.E7Action;
import com.e7.service.CaptchaService;
import com.opensymphony.xwork2.Action;

@Component("captchaAction")
public class CaptchaAction extends E7Action {
	private static final long serialVersionUID = -290143290121065915L;
	private CaptchaService captchaService;

	// client set
	private String seed;
	// return
	private InputStream inputStream;

	public String refresh() throws IOException {
		InputStream is = this.captchaService.generate(this.seed);
		this.setInputStream(is);
		return Action.SUCCESS;
	}

	public InputStream getInputStream() {
		return inputStream;
	}

	public void setInputStream(InputStream is) {
		this.inputStream = is;
	}

	public void setCaptchaService(CaptchaService captchaService) {
		this.captchaService = captchaService;
	}
}
